Developer Documentation

QuickTime 4 API Documentation

QuickTime 4 Reference

| Previous | Chapter Contents | Chapter Top | Next |

Using a kTweenTypePathToMatrixTranslation Tween Component

To use a kTweenTypePathToMatrixTranslation tween component, do the following:

  1. Create a QT atom container.
  2. Insert a kTweenEntry atom into the QT atom container for the tween.
  3. Insert a kTweenType atom that specifies the tween type into the kTweenEntry atom.
  4. Insert a kTweenData atom into the kTweenEntry atom.
  5. Perform the tweening operation, using QTDoTween .

Listing 11 shows how to create a kTweenTypePathToMatrixTranslation tween.

Listing 11 Creating a kTweenTypePathToMatrixTranslation tween container

OSErr               err = noErr;
TimeValue           tweenTime, duration;
Handle              result = nil;
QTAtomContainer     container = nil;
QTTweener           tween = nil;
QTAtom              tweenAtom;

duration = 8;

result = NewHandle( 0 );
if ( err = MemError() ) goto bail;

err = QTNewAtomContainer( &container );
if ( err ) goto bail;

err = CreateSamplePathTweenContainer( container,
                                    kTweenTypePathToMatrixTranslation, 1,
                                    false, duration, 0, &tweenAtom );
if ( err ) goto bail;

err = QTNewTween( &tween, container, tweenAtom, duration );
if ( err ) goto bail;

for ( tweenTime = 0; tweenTime <= duration; tweenTime++ ) {
    MatrixRecord absoluteMatrix;
    
    err = QTDoTween( tween, tweenTime, result, nil, nil, nil );
    if ( err ) goto bail;
    
    absoluteMatrix = *(MatrixRecord *)*result;
}
    
err = QTDisposeTween( tween );

bail:
    if ( container ) QTDisposeAtomContainer( container );
    if ( result ) DisposeHandle( result );

Listing 12 shows how to create a kTweenTypePathToMatrixTranslation tween in which the the kTweenReturnDelta flag is set.

Listing 12 Creating a kTweenTypePathToMatrixTranslation tween

err = CreateSamplePathTweenContainer( container,
                                    kTweenTypePathToMatrixTranslation, 1,
                                    true, duration, 0, &tweenAtom );
if ( err ) goto bail;

err = QTNewTween( &tween, container, tweenAtom, duration );
if ( err ) goto bail;

for ( tweenTime = 0; tweenTime <= duration; tweenTime++ ) {
    MatrixRecord deltaMatrix;
    
    err = QTDoTween( tween, tweenTime, result, nil, nil, nil );
    if ( err ) goto bail;
    
    deltaMatrix = *(MatrixRecord *)*result;
}
    
err = QTDisposeTween( tween );

bail:
    if ( container ) QTDisposeAtomContainer( container );
    if ( result ) DisposeHandle( result );

© 1999 Apple Computer, Inc.

| Previous | Chapter Contents | Chapter Top | Next |